﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace CFR.Silverlight.Scheduling
{
    public abstract class ViewBase : Control, INotifyPropertyChanged
    {

           #region Scheduler (DependencyProperty)

        /// <summary>
        /// Gets or sets the scheduler that the view belongs to.
        /// </summary>
        public Scheduler Scheduler
        {
            get { return (Scheduler)GetValue(SchedulerProperty); }
            set { SetValue(SchedulerProperty, value); }
        }
        public static readonly DependencyProperty SchedulerProperty =
            DependencyProperty.Register("Scheduler", typeof(Scheduler), typeof(ViewBase),
              new PropertyMetadata(null));

        #endregion

        public ViewBase(Scheduler scheduler)
        {

            this.Scheduler = scheduler;

            scheduler.StartDateChanged += new EventHandler(OnStartDateChanged);
            scheduler.EndDateChanged += new EventHandler(OnEndDateChanged);
        }
        public ViewBase() { }

        protected virtual void OnEndDateChanged(object sender, EventArgs e)
        {

        }

        protected virtual void OnStartDateChanged(object sender, EventArgs e)
        {

        }


        protected internal virtual void Refresh()
        {

        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }
}
